package cool.doudou.doudada.wechat.auto.configuration;

import cool.doudou.doudada.wechat.config.WechatConfig;
import cool.doudou.doudada.wechat.core.helper.ReplyMsgHelper;
import cool.doudou.doudada.wechat.core.helper.TokenHelper;
import cool.doudou.doudada.wechat.properties.WechatProperties;
import cool.doudou.doudada.wechat.rest.service.WechatService;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;

/**
 * WechatAutoConfiguration
 *
 * @author jiangcs
 * @since 2022/2/19
 */
@EnableConfigurationProperties({WechatProperties.class})
@Import({WechatConfig.class})
@AutoConfiguration
public class WechatAutoConfiguration {
    @ConditionalOnMissingBean(TokenHelper.class)
    @Bean
    public TokenHelper tokenHelper() {
        return new TokenHelper();
    }

    @ConditionalOnMissingBean(ReplyMsgHelper.class)
    @Bean
    public ReplyMsgHelper replyMsgHelper() {
        return new ReplyMsgHelper();
    }

    @ConditionalOnMissingBean(WechatService.class)
    @Bean
    public WechatService wechatService() {
        return new WechatService();
    }
}
